package communication;

import util.ConfigFile;
import util.Utils;

public class SimpleXYMessage {

	private float x;
	private float y;
	
	public SimpleXYMessage(float x, float y) {
		super();
		this.x = x;
		this.y = y;
		//this.normalizeMessageContent();
	}

	public float getX() {
		return x;
	}

	public void setX(float x) {
		this.x = x;
	}

	public float getY() {
		return y;
	}

	public void setY(float y) {
		this.y = y;
	}
	
	public void normalizeMessageContent(){
		float x = this.getX();
		float y = this.getY();
		float messageRangeXMin = ConfigFile.getFloat("messageRangeX.min");
		float messageRangeXMax = ConfigFile.getFloat("messageRangeX.max");
		float messageRangeYMin = ConfigFile.getFloat("messageRangeY.min");
		float messageRangeYMax = ConfigFile.getFloat("messageRangeY.max");
		float newX = Utils.map(x, messageRangeXMin, messageRangeXMax, 0.0f, 1.0f);
		float newY = Utils.map(y, messageRangeYMin, messageRangeYMax, 0.0f, 1.0f);
		this.setX(newX);
		this.setY(newY);
	}

	@Override
	public String toString() {
		return "x:" + this.x + " y:" + this.y;
	}
	
}
